package ch.wanandroid.present;

import java.lang.ref.WeakReference;

/**
 * Author: ch
 * Date: 2018/10/22 14:02
 * Description: ${DESCRIPTION}
 */

public abstract class BasePresenter<V> {

    protected WeakReference<V> mViewRef;

    public void attachView(V view) {
        mViewRef = new WeakReference<>(view);
    }

    public void detachView() {
        if (mViewRef != null) {
            mViewRef.clear();
            mViewRef = null;
        }
    }

    protected V getView() {
        return mViewRef.get();
    }

}
